package com.itlaobing.spring.ioc.instantiating;

import org.springframework.beans.factory.FactoryBean;

import java.util.logging.Logger;

public class BusFactoryBean implements FactoryBean<Bus> {

    private Logger logger = Logger.getLogger(this.getClass().getName());

    public BusFactoryBean(){
        super();
        logger.info("BusFactoryBean()");
    }

    @Override
    public Bus getObject() throws Exception {
        logger.info("getObect()");
        Bus bus =new Bus(); //创建 Bus 实例
        bus.setBrand("宇通");
        return bus;
    }

    @Override
    public Class<?> getObjectType() {
        return Bus.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
